import React from 'react';

// 子组件
export class Child extends React.Component {
  constructor() {
    console.log('子组件=> 1. constructor()');
    super();
    this.timerId = setInterval(() => {
      console.log('计时器id', this.timerId);
    }, 500);
  }

  render() {
    console.log('子组件=> 2. render');
    return (
      <div>
        <h3>子组件内容：{this.props.count}</h3>
      </div>
    );
  }

  componentDidMount() {
    console.log('子组件=> 3. componentDidMount()');
  }

  componentDidUpdate() {
    console.log('子组件=> 4. componentDidUpdate()');
  }

  componentWillUnmount() {
    clearInterval(this.timerId);
    console.log('子组件=> 5. componentWillUnmount()');
  }
}
